package message;
//This is newest version
public class head {
	String destination;
	String sendTime;
	String sequence;
	String source;
	int type;

	public String getDestination() {
		return destination;
	}

	public String getSendTime() {
		return sendTime;
	}

	public String getSequence() {
		return sequence;
	}

	public String getSource() {
		return source;
	}

	public int getType() {
		return type;
	}

	public void setSource(String Source) {
		this.source = Source;
	}

	public void setSendTime(String sendTime) {
		try {
			if (sendTime.length() != 14)
				throw new Exception("sendTime的长度应设置为14");
			else
				this.sendTime = sendTime;
		} catch (Exception e) {
			System.out.println(e);
		}
	}

	public void setSequence(String sequence) {
		this.sequence = sequence;
		try {
			if (sequence.length() != 13)
				throw new Exception("sequence的长度应设置为13");
			else
				this.sequence = sequence;
		} catch (Exception e) {
			System.out.println(e);
		}
	}

	public void setDestination(String destination) {
		this.destination = destination;
	}

	public void setType(int type) {
		try {
			if (type < 10 || type > 99)
				throw new Exception("type应设置为10到99之间");
			else
				this.type = type;
		} catch (Exception e) {
			System.out.println(e);
		}
	}

	@Override
	public String toString() {
		return getSource() + "^" + getDestination() + "^" + getType() + "^"
				+ getSendTime() + "^" + getSequence() + "^$";
	}

}
